{include file="news/header.tpl"}
{literal}
<style type="text/css">
#main {color:#333}
textarea{border:1px solid #ddd; font-size:14px;color:#000;width:90%;padding-left:28px;}
.grey{color:#999}
#msg1,#msg2,#msg3,#msg4{ display:none}
#ol{position:absolute; z-index:1; padding:0px; margin:0px; border:0px; background:#ecf0f5;width:23px; text-align:left;  }
#li{background:#fff; height:480px; overflow:hidden; width:32px; border-right: 1px solid #DDD; line-height:20px; margin:0px; padding:0px;text-align:center}
#c2{background-color:#FEFBF3;color:#000;padding-left:35px;}
</style>
<script language="javascript" type="text/javascript">
	
String.prototype.trim2 = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function F(objid){
	return document.getElementById(objid).value;
}
function G(objid){
	return document.getElementById(objid);
}


function save(){

var c=$("#c2").val();

var d=$("#tempid").val();
var remark=$("input[name='remark']").val();

if(remark.length<6){
   alert('备注小于6个字符');
   return false;
}

$.post("/temp/savetemp",{source:c,id:d,remark:remark},function(result){
	if(result.status==true){
alert(result.message);
		//$("#notice").fadeIn(result.error,5000);
		}else{
			alert(result.message);
			
			//$("#notice").html(result.error);
			}
},"json")
}

</script>
{/literal}
{include file="news/top.tpl"}
<body onload="keyUp();">

<!-- 头部// -->


{include file="news/nav.tpl"}
	<!-- start: Content -->
			<div id="content" class="span10">
			
						
			<div class="row-fluid">


<div class="box span12"><!-- Default panel contents -->


<div class="box-content">
  
  <div class="panel-heading">{$tempinfo.name} |{$tempinfo.remark} >> {$notice}</div>
<table class=table>





 <form action="/temp/saveTemp" method="post">
<input type="hidden" name="id" id="tempid" class="form-control" value="{$tempinfo.id}"> 

<tr>
<td >
 <div id="ol"><textarea cols="2" rows="10" id="li" disabled></textarea></div>
    <textarea name="co" cols="146" rows="25"  id="c2"  onblur="check('2')" onkeyup="keyUp()"  onscroll="G('li').scrollTop = this.scrollTop;" oncontextmenu="return false"  class="grey">{$tempinfo.source}
</textarea>    
 </td>
</tr>

</form>

<tr>
<td>
备注:<input type="text" name=remark  class="control">
<input type="button" value="保存" onclick="return save();" class="btn btn-primary">
</td>
</tr>

</table>
</div>
</div>
 </div>  
{literal}

<script language="javascript" type="text/javascript">
var msgA=["msg1","msg2","msg3","msg4"];
var c=["c1","c2","c3","c4"];
var slen=[50,20000,20000,60];//允许最大字数
var num="";
var isfirst=[0,0,0,0,0,0];
function isEmpty(strVal){
	if( strVal == "" )
		return true;
	else
		return false;
}
function isBlank(testVal){		
    var regVal=/^\s*$/;
    return (regVal.test(testVal))
}
function chLen(strVal){
	strVal=strVal.trim2();
	var cArr = strVal.match(/[^\x00-\xff]/ig);
    return strVal.length + (cArr == null ? 0 : cArr.length);   	
}
function check(i){
	var iValue=F("c"+i);
	var iObj=G("msg"+i);
	var n=(chLen(iValue)>slen[i-1]);
	if((isBlank(iValue)==true)||(isEmpty(iValue)==true)||n==true){		
		iObj.style.display ="block";
	}else{		
		iObj.style.display ="none";
	}
}
function checkAll(){
	for(var i=0;i<msgA.length; i++){
		check(i+1);		
		if(G(msgA[i]).style.display=="none"){
			continue;
		}else{
			alert("填写错误,请查看提示信息！");
			return;
		}
	}
	G("form1").submit();	
}
function clearValue(i){
	G(c[i-1]).style.color="#000";
	keyUp();	
	if(isfirst[i]==0){
		G(c[i-1]).value="";
	}
	isfirst[i]=1;
}
function keyUp(){
	var obj=G("c2");
	var str=obj.value;	
	str=str.replace(/\r/gi,"");
	str=str.split("\n");
	n=str.length;
	line(n);
}
function line(n){
	var lineobj=G("li");
	for(var i=1;i<=n;i++){
		if(document.all){
			num+=i+"\r\n";
		}else{
			num+=i+"\n";
		}
	}
	lineobj.value=num;
	num="";
}
function autoScroll(){
	var nV = 0;
	if(!document.all){
		nV=G("c2").scrollTop;
		G("li").scrollTop=nV;
		setTimeout("autoScroll()",20);
	}	
}
if(!document.all){
window.addEventListener("load",autoScroll,false);
}
</script>
{/literal}
{include file="news/footer.tpl"}
